<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ page import="util.Info" %>
<%@ page import="dao.CommDAO" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    CommDAO dao = new CommDAO();
    String id = request.getParameter("id");
    HashMap map = dao.select("select s.*,sy.*,d.* from schedule s left join sysuser sy on s.doctor_id = sy.id and sy.utype = '医生' left join dept d on d.id = sy.dept where s.id=" + id).get(0);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title>排班修改</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <LINK href="admin/css/admin.css" type="text/css" rel="stylesheet">
    <style>
        select {
            width: 150px;
        }
    </style>
</head>
<body>
<form action="/srykzsblmis/studysite?ac=pbedit" name="f1" method="post" onsubmit="return ck()">
    <input type="hidden" name="id" value="<%=id%>">
    <TABLE cellSpacing=0 cellPadding=0 width="95%" align=center border=0>
        <TR height=20>
            <TD></TD>
        </TR>
        <TR height=22>
            <TD style="PADDING-LEFT: 20px; FONT-WEIGHT: bold; COLOR: #ffffff"
                align=middle background=admin/images/title_bg2.jpg>排班修改
            </TD>
        </TR>
        <TR bgColor=#ecf4fc height=12>
            <TD></TD>
        </TR>
        <TR height=20>
            <TD></TD>
        </TR>
    </TABLE>
    <TABLE cellSpacing=1 cellPadding=2 width="95%" align=center border=0 bgcolor="#cccccc">
        <tr bgcolor="#ffffff">
            <td>科室</td>
            <td>
                <select id="dept" name="dept">
                    <option value="">请选择</option>
                    <%
                        ArrayList<HashMap> deptlist = (ArrayList<HashMap>) dao.select("select * from dept where delstatus='0'");
                        for (HashMap deptm : deptlist) {
                            String selected = deptm.get("id").toString().equals(map.get("dept").toString()) ? "selected" : "";
                    %>
                    <option value="<%=deptm.get("id") %>" <%=selected%>><%=deptm.get("deptname") %>
                    </option>
                    <% } %>
                </select>*
            </td>
        </tr>
        <tr bgcolor="#ffffff">
            <td>医生</td>
            <td>
                <select id="doc" name="doctor_id">
                    <option value="">请选择</option>
                    <%
                        ArrayList<HashMap> doclist = (ArrayList<HashMap>) dao.select("select s.* from sysuser s left join dept d on s.dept = d.id where s.utype = '医生'");
                        for (HashMap docm : doclist) {
                            String selected = docm.get("id").toString().equals(map.get("doctor_id").toString()) ? "selected" : "";
                    %>
                    <option value="<%=docm.get("id") %>" <%=selected%>><%=docm.get("tname") %>
                    </option>
                    <% } %>
                </select>*
            </td>
        </tr>
        <tr bgcolor="#ffffff">
            <td>日期</td>
            <td>
                <select id="date" name="shift_date">
                    <option value="">请选择</option>
                    <%
                        String[] days = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};
                        for (String day : days) {
                            String selected = day.equals(map.get("shift_date")) ? "selected" : "";
                    %>
                    <option value="<%=day%>" <%=selected%>><%=day%>
                    </option>
                    <% } %>
                </select>*
            </td>
        </tr>
        <tr bgcolor="#ffffff">
            <td>时间</td>
            <td>
                <select id="time" name="shift_time">
                    <option value="">请选择</option>
                    <%
                        String[] times = {"上午", "下午"};
                        for (String time : times) {
                            String selected = time.equals(map.get("shift_time")) ? "selected" : "";
                    %>
                    <option value="<%=time%>" <%=selected%>><%=time%>
                    </option>
                    <% } %>
                </select>*
            </td>
        </tr>
        <tr bgcolor="#ffffff">
            <td>状态</td>
            <td>
                <select id="status" name="status">
                    <option value="">请选择</option>
                    <%
                        String[] status = {"预约", "停诊"};
                        for (String st : status) {
                            String selected = st.equals(map.get("status")) ? "selected" : "";
                    %>
                    <option value="<%=st%>" <%=selected%>><%=st%>
                    </option>
                    <% } %>
                </select>*
            </td>
        </tr>
        <tr bgcolor="#ffffff">
            <td colspan="2">
                <input type="submit" value="提交"/>
                <input type="reset" value="重置"/>
            </td>
        </tr>
    </TABLE>
</form>
</body>
</html>
<script type="text/javascript">
    function ck() {
        if (f1.dept.value == "") {
            alert("科室不能为空");
            return false;
        }
        if (f1.doc.value == "") {
            alert("医生不能为空");
            return false;
        }
        if (f1.date.value == "") {
            alert("日期不能为空");
            return false;
        }
        if (f1.time.value == "") {
            alert("时间不能为空");
            return false;
        }
    }

    <%
        String suc = (String) request.getAttribute("suc");
        String no = (String) request.getAttribute("no");
        if (no != null) {
    %>
    alert("已存在");
    <%
        }
        if (suc != null) {
    %>
    alert("操作成功");
    location.replace("/srykzsblmis/admin/pblist.jsp");
    <%
        }
    %>
</script>
